package com.dy.cloud.controller;

import com.dy.cloud.pojo.Entity.PaymentEntity;
import com.dy.cloud.service.PaymentFeignService;
import com.dy.cloud.util.ApiResousUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName:
 * @Author: 仄言in
 * @Desctiption: (描述)
 * @Date: 2021/9/15 8:57
 * @Version 1.0 (版本)
 */
@RestController
@RequestMapping("/feign")
@Slf4j
public class PaymentFeignController {
    @Value("${server.port}")
    private String port;
    @Autowired
    private PaymentFeignService paymentFeignService;

    /**
     * 全查询
     * @return ApiResousUtil
     **/
    @GetMapping("/list")
    public ApiResousUtil<List> list(){
        return ApiResousUtil.ok(paymentFeignService.list()+"port"+port);
    }
    /**
     * 添加
     * @param  payment
     * @return ApiResousUtil
     **/
    @PostMapping("/save")
    public ApiResousUtil save(@RequestBody PaymentEntity payment){
        return ApiResousUtil.ok(paymentFeignService.save(payment)+"port"+port);
    }
    /**
     * 删除
     * @param id
     * @return
     **/
    @GetMapping("/deleteById/{id}")
    public ApiResousUtil<String> deleteById(@PathVariable("id") Long id){
        return ApiResousUtil.ok(paymentFeignService.deleteById(id)+"port"+port);
    }
    /**
     * 根据id查询
     * @param id
     * @return
     **/
    @GetMapping("/selectById/{id}")
    public ApiResousUtil<String> selectById(@PathVariable("id") Long id){
        return ApiResousUtil.ok(paymentFeignService.selectById(id)+"port"+port);

    }
    /**
     * 修改
     * @param payment
     * @return
     **/
    @PostMapping("/updateById")
    public ApiResousUtil<String> updateById(@RequestBody PaymentEntity payment){
        return ApiResousUtil.ok(paymentFeignService.updateById(payment)+"port"+port);
    }
}
